/**
 * Copyright (C) 2013 The yydorid-framework project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.yangying.androidframework.util;

import java.io.PrintStream;
import java.lang.reflect.Method;

/**
 * LogUtil�����ࣺ��־����Ŀ���
 * 
 * @author YANGYING
 * 
 * @date 2011-5-25
 */
public class LogUtil {

	private static String TAG = "YYDroid";
	public static boolean debug;

	private static Class debugClass;
	static {
		try {
			debugClass = Class.forName("android.util.Log");
		} catch (ClassNotFoundException localClassNotFoundException) {
			localClassNotFoundException.printStackTrace();
		}
	}

	public static void d(CharSequence paramCharSequence) {
		if (debug && (!TextUtil.isEmpty(paramCharSequence))) {
			String str1 = TAG;
			String str2 = paramCharSequence.toString();
			Log.d(str1, str2);
		}
	}

	public static void e(CharSequence paramCharSequence) {
		if (debug && (!TextUtil.isEmpty(paramCharSequence))) {
			String str1 = TAG;
			String str2 = paramCharSequence.toString();
			Log.e(str1, str2);
		}
	}

	public static void i(CharSequence paramCharSequence) {
		if (debug && (!TextUtil.isEmpty(paramCharSequence))) {
			String str1 = TAG;
			String str2 = paramCharSequence.toString();
			Log.i(str1, str2);
		}
	}

	static class Log {
		static void d(String paramString1, String paramString2) {
			if (LogUtil.debugClass != null) {
				try {
					Class localClass = LogUtil.debugClass;
					Class[] arrayOfClass = new Class[2];
					arrayOfClass[0] = String.class;
					arrayOfClass[1] = String.class;
					Method localMethod = localClass
							.getMethod("d", arrayOfClass);
					Object[] arrayOfObject = new Object[2];
					arrayOfObject[0] = paramString1;
					arrayOfObject[1] = paramString2;
					localMethod.invoke(localClass, arrayOfObject);
					return;
				} catch (Exception localException) {
				}
				PrintStream localPrintStream = System.out;
				String str1 = String.valueOf(paramString1);
				String str2 = str1 + " -- " + paramString2;
				localPrintStream.println(str2);
			}
		}

		static void e(String paramString1, String paramString2) {
			if (LogUtil.debugClass != null) {
				try {
					Class localClass = LogUtil.debugClass;
					Class[] arrayOfClass = new Class[2];
					arrayOfClass[0] = String.class;
					arrayOfClass[1] = String.class;
					Method localMethod = localClass
							.getMethod("e", arrayOfClass);
					Object[] arrayOfObject = new Object[2];
					arrayOfObject[0] = paramString1;
					arrayOfObject[1] = paramString2;
					localMethod.invoke(localClass, arrayOfObject);
					return;
				} catch (Exception localException) {
				}
				PrintStream localPrintStream = System.err;
				String str1 = String.valueOf(paramString1);
				String str2 = str1 + " -- " + paramString2;
				localPrintStream.println(str2);
			}
		}

		static void i(String paramString1, String paramString2) {
			if (LogUtil.debugClass != null) {
				try {
					Class localClass = LogUtil.debugClass;
					Class[] arrayOfClass = new Class[2];
					arrayOfClass[0] = String.class;
					arrayOfClass[1] = String.class;
					Method localMethod = localClass
							.getMethod("i", arrayOfClass);
					Object[] arrayOfObject = new Object[2];
					arrayOfObject[0] = paramString1;
					arrayOfObject[1] = paramString2;
					localMethod.invoke(localClass, arrayOfObject);
					return;
				} catch (Exception localException) {
				}
				PrintStream localPrintStream = System.out;
				String str1 = String.valueOf(paramString1);
				String str2 = str1 + " -- " + paramString2;
				localPrintStream.println(str2);
			}
		}

	}
}
